package com.bthdung.studios.lesson12;

import android.app.Activity;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

/*
 * Main Activity 
 * Thông tin chính sử dụng OpenGL ES 2.0
 * Các cài đặt chuwong trình nên để ở đây
 */
public class RenderActivity extends Activity
{
	GLES20SurfaceView glView;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);

		setVolumeControlStream(AudioManager.STREAM_MUSIC);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

		glView = new GLES20SurfaceView(this);
		setContentView(glView);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{
		if (keyCode == KeyEvent.KEYCODE_BACK)
		{
			setResult(RESULT_OK);
			finish();
			return true;
		}

		return super.onKeyDown(keyCode, event);
	}

	@Override
	protected void onResume()
	{
		super.onResume();
		glView.onResume();
	}

	@Override
	protected void onPause()
	{
		super.onPause();
		glView.onPause();
	}
}